package com.yanqu.road.server.cmd.activity.commonwish;

import com.yanqu.road.entity.activity.commonwish.CommonWishConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CommonWishProto;
import com.yanqu.road.pb.activity.FanxiuspringProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.commonwish.CommonWishMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = CommonWishProto.CommonWishNoticeReqMsg.class, respMsg = CommonWishProto.CommonWishNoticeRespMsg.class)
@Cmd(code = Protocol.S_COMMON_WISH_NOTICE, desc = "获取抽奖公告")
public class CommonWishDrawNoticeListCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        FanxiuspringProto.CrossFanXiuSpringNoticeReqMsg reqMsg = FanxiuspringProto.CrossFanXiuSpringNoticeReqMsg.parseFrom(packet.getBytes());
        // 没有活动
        CommonWishConfig config = CommonWishMgr.getCommonWishConfig(reqMsg.getActivityId());
        if (config == null || !ActivityMgr.activityInShowTime(config.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        player.sendPacket(Protocol.C_COMMON_WISH_GET_DRAW_NOTICE_LIST, reqMsg.toBuilder());

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
